import { RouteRecordRaw } from "vue-router";
import HomeView from "@/views/HomeView.vue";
import AdminView from "@/views/AdminView.vue";
import NoAuthView from "@/views/NoAuthView.vue";
import AccessEnum from "@/access/AccessEnum";
import UserLayout from "@/layouts/UserLayout.vue";
import UserLoginView from "@/views/user/UserLoginView.vue";
import UserRegisterView from "@/views/user/UserRegisterView.vue";
import AddQuestionView from "@/views/question/AddQuestionView.vue";
import ManageQuestionView from "@/views/question/ManageQuestionView.vue";
import QuestionView from "@/views/question/QuestionView.vue";
import ViewQuestionView from "@/views/question/ViewQuestionView.vue";
import ViewArticle from "@/views/article/ViewArticleView.vue";
import AboutView from "@/views/AboutView.vue";
import HomeVideoView from "@/views/video/HomeVideoView.vue";
import AddVideoView from "@/views/video/UserCreaterView.vue";
import ViewVideoView from "@/views/video/ViewVideoView.vue";
import UserAddVideo from "@/components/UserAddVideo.vue";
import UserAddActicle from "@/components/UserAddActicle.vue";

export const routes: Array<RouteRecordRaw> = [
  {
    path: "/user",
    name: "用户",
    component: UserLayout,
    meta: {
      hideInMenu: true,
    },
    children: [
      {
        path: "/user/login",
        name: "用户登录",
        component: UserLoginView,
      },
      {
        path: "/user/register",
        name: "用户注册",
        component: UserRegisterView,
      },
    ],
  },
  {
    path: "/",
    name: "主页",
    component: HomeView,
    meta: {
      access: AccessEnum.USER,
    },
  },
  {
    path: "/questions",
    name: "浏览题目",
    component: QuestionView,
  },
  {
    path: "/view/questions/:id",
    name: "在线做题",
    component: ViewQuestionView,
    props: true,
    meta: {
      hideInMenu: true,
      access: AccessEnum.USER,
    },
  },
  {
    path: "/view/article/:id",
    name: "文章页面",
    component: ViewArticle,
    props: true,
    meta: {
      hideInMenu: true,
      access: AccessEnum.USER,
    },
  },
  {
    path: "/add/question",
    name: "创建题目",
    component: AddQuestionView,
    meta: {
      access: AccessEnum.USER,
    },
  },
  {
    path: "/update/question",
    name: "更新题目",
    component: AddQuestionView,
    meta: {
      access: AccessEnum.USER,
      hideInMenu: true,
    },
  },
  {
    path: "/manage/question",
    name: "管理题目",
    component: ManageQuestionView,
    meta: {
      access: AccessEnum.USER,
    },
  },
  {
    path: "/admin",
    name: "管理员",
    component: AdminView,
    meta: {
      hideInMenu: true,
    },
  },
  {
    path: "/hide",
    name: "隐藏页面",
    component: AboutView,
    meta: {
      hideInMenu: false,
    },
  },
  {
    path: "/vidoe",
    name: "视频主页",
    component: HomeVideoView,
    meta: {
      hideInMenu: false,
    },
    children: [
      {
        path: "/video/viewVideo",
        name: "观看视频单个",
        component: ViewVideoView,
      },
    ],
  },
  {
    path: "/userCreate",
    name: "创作中心",
    component: AddVideoView,
    children: [
      {
        path: "/userCreate/addVideo",
        name: "用户上传视频",
        component: UserAddVideo,
      },
      {
        path: "/userCreate/addActicle",
        name: "用户上传文章",
        component: UserAddActicle,
      },
    ],
  },
  {
    path: "/noAuth",
    name: "无权限",
    component: NoAuthView,
    meta: {
      hideInMenu: true,
    },
  },
  {
    path: "/about",
    name: "关于我的",
    meta: {
      hideInMenu: true,
    },
    // route level code-splitting
    // this generates a separate chunk (about.[hash].js) for this route
    // which is lazy-loaded when the route is visited.
    component: () =>
      import(/* webpackChunkName: "about" */ "../views/AboutView.vue"),
  },
];
